<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>
<script>
import BScroll, { PullUpLoad } from "better-scroll";
import ObserveImage from '@better-scroll/observe-image'
BScroll.use(ObserveImage)
export default {
  data() {
    return {
      scroll: null,
    };
  },
  props:{
    probeType:{
      type:Number,
      default:3
    },
    pullUpLoad:{
      type:Boolean,
      default:true
    }
  },
  mounted() {
    this.scroll = new BScroll(this.$refs.wrapper, {
      click: true,
      probeType: this.probeType,
      pullUpLoad: this.pullUpLoad,
      observeDOM: true,
      observeImage: true
    });
    this.scroll.on('scroll',(position)=>{
      this.$emit('scroll',position)
    })
    this.scroll.on('pullingUp',()=>{
      this.$emit('pullingUp')
    })
    
  },
  methods:{
    scrollTo(x,y,time = 400){
      this.scroll.scrollTo(x,y,time)
      console.log(this.scroll);
    },
    finishPullUp(){
      this.scroll.finishPullUp()
    },
    getscrollY(){
      return this.scroll.y
    }
      
     
   
  }
};
</script>